// pages/problemList/problemList.js 
const app = getApp()
const util = require('../../utils/util.js')
const lbbService = require('../service/service.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    sysProblemList: [],
    serProblemList: [],
    onSiteFeedbackList: [],
    otherProblemList:[{questionName:'未巡检待处理设备',num:5},{questionName:'未巡检待处理控制盒',num:6}],
    isMaintenanceUser:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    if(options.hospitalId){
      this.setData({
        scrollHeight:app.getScrollHeight(0),
        hospitalId: options.hospitalId,
        hospitalName:options.hospitalName
      })
      wx.setNavigationBarTitle({
        title: '问题统计('+options.hospitalName+')',
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    let that = this
    if (that.data.hospitalId) {
      lbbService.getAllQuestions({ hospitalId: parseInt(that.data.hospitalId) },function(res){
        that.setData({
          serProblemList: res.data.submitFeedbackMap,
          onSiteFeedbackList: res.data.onSiteFeedbackMap
        })
      })
      lbbService.getAllPartsDepreciationNum({hospitalId: parseInt(that.data.hospitalId)},function (res) {
        that.setData({
            oldEquNum:res.data.equNum,
            oldPileNum:res.data.pileNum,
            unInspectEquNum:res.data.unInspectEquNum,
            unInspectPileNum:res.data.unInspectPileNum,
            unInspectEquHandleNum:res.data.unInspectEquHandleNum,
            unInspectPileHandleNum:res.data.unInspectPileHandleNum,
            unInspectEquHandleOnPileNum:res.data.unInspectEquHandleOnPileNum,
            isMaintenanceUser:res.data.isMaintenanceUser,
            oneMinuteNum:res.data.oneMinuteNum,
            twoMinuteNum:res.data.twoMinuteNum,
            moreFiveMinuteNum:res.data.moreFiveMinuteNum
         }) 
      })
    } else {
      lbbService.getAllQuestions({}, function(res){
        that.setData({
          serProblemList: res.data.submitFeedbackMap,
          onSiteFeedbackList: res.data.onSiteFeedbackMap
        })
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },
})